import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Index from "../views/Index.vue"
import HealthManagement from "../views/HealthManagement"
import Mater from "../views/Mater.vue"
import SearPop from "../views/SearPop.vue"
import Details from "../views/Details.vue"
import DetailPage from "../views/DetailPage.vue"
import Next from "../views/Next.vue"



///////////////////////////////张润泽
import Login from '../views/Login.vue'
import My from '../views/My.vue'
import Mi from '../views/Mi.vue'
import Phone from '../views/Phone.vue'
import Phone_Cz from '../views/Phone_Cz.vue'
import Yhxy from '../views/Yhxy.vue'
import Ystk from '../views/Ystk.vue'
////////////////////////////////


//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
//修改原型对象中的push函数
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Index',
    component: Index,
    children:[
      {
        path: 'popu',//首页的子路由组件
        name: 'SearPop',
        component: () => import(/* webpackChunkName: "about" */ '../views/SearPop.vue')
      }
    ]
  },
  {//详情页面路由
    path: '/detail',
    name: 'DetailPage.',
    component: () => import(/* webpackChunkName: "DetailPage." */ '../views/DetailPage.vue')
  },
  {
    path: '/details',
    name: 'Details',
    component: () => import(/* webpackChunkName: "Details" */ '../views/Details.vue')
  },
  {
    path: '/mater',
    name: 'Mater',
    component: () => import(/* webpackChunkName: "mater" */ '../views/Mater.vue')
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/classroom',//课堂页面
    name: 'Classroom',
    component: () => import(/* webpackChunkName: "mine" */ '../views/Classroom.vue')
  },
  {
    path: '/food',//晒美食
    name: 'Food',
    component: () => import(/* webpackChunkName: "mine" */ '../views/Food.vue')
  },
  {
    path:"/health",
    component:HealthManagement
  },
  {
    path:"/next",
    component:Next
  },
  ///张润泽
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/login_my',
    name: 'My',
    component: My
  },
  {
    path: '/login_mi',
    name: 'Mi',
    component: Mi
  },
  {
    path: '/login_my_yhxy',
    name: 'Yhxy',
    component: Yhxy
  },
  {
    path: '/login_my_ystk',
    name: 'Ystk',
    component: Ystk
  },
  {
    path: '/login_phone',
    name: 'Phone',
    component: Phone
  },
  {
    path: '/login_Mi_PhoneCz',
    name: 'Phone_Cz',
    component: Phone_Cz
  },
]

const router = new VueRouter({
  mode:"history",//去除#号
  routes
})


/**
 * 实现路由拦截  (导航守卫)
 * 三个参数
 * to   代表即将进入的路由
 * from  代表即将离开的路由
 * next()  每一个导航守卫必须知道搭配一个next()
 */
// router.beforeEach((to,from,next)=>{
//   console.log("to:",to)
//   console.log("from:",from)
// })


export default router;
